home *** CD-ROM | disk | FTP | other *** search
- class Track extends Array
- {
- var scenery;
- var oscen;
- var pickups;
- var opicks;
- var warnings;
- var owarn;
- var scale = 1;
- var vscale = 1;
- var l = 0;
- var angle = 0;
- function Track()
- {
- super();
- if(arguments.length > 1)
- {
- this.splice.apply(this,[0,0].concat(arguments));
- }
- else if(arguments.length == 1)
- {
- var _loc4_ = 0;
- while(_loc4_ < arguments[0])
- {
- this[_loc4_] = undefined;
- _loc4_ = _loc4_ + 1;
- }
- }
- }
- function reset()
- {
- this.scenery = this.oscen.copy();
- this.pickups = this.opicks.copy();
- this.warnings = this.owarn.copy();
- }
- function setScenery(s)
- {
- this.oscen = s;
- this.scenery = s.copy();
- }
- function setPickups(p)
- {
- this.opicks = p;
- this.pickups = p.copy();
- }
- function setWarnings(w)
- {
- this.owarn = w;
- this.warnings = w.copy();
- }
- function analyse(ia)
- {
- this.angle = ia != undefined ? ia : this.angle;
- var _loc4_ = 0;
- var _loc3_ = 0;
- var _loc2_ = 0;
- while(_loc2_ < this.length)
- {
- this[_loc2_].a = this.angle;
- this[_loc2_].z *= this.vscale;
- if(this[_loc2_].s)
- {
- this[_loc2_].l *= this.scale;
- this[_loc2_].x = _loc4_;
- this[_loc2_].y = _loc3_;
- _loc4_ += this[_loc2_].l * Math.cos(this[_loc2_].a);
- _loc3_ += this[_loc2_].l * Math.sin(this[_loc2_].a);
- }
- else
- {
- this[_loc2_].c *= Trig.dr;
- this[_loc2_].r *= this.scale;
- this[_loc2_].l = this[_loc2_].r * this[_loc2_].c;
- this.angle += this[_loc2_].c * this[_loc2_].d;
- this[_loc2_].x = _loc4_;
- this[_loc2_].y = _loc3_;
- var _loc5_ = this[_loc2_].a + Trig.ra * this[_loc2_].d;
- this[_loc2_].cx = _loc4_ + this[_loc2_].r * Math.cos(_loc5_);
- this[_loc2_].cy = _loc3_ + this[_loc2_].r * Math.sin(_loc5_);
- _loc4_ = this[_loc2_].cx + this[_loc2_].r * Math.cos(this[_loc2_].c * this[_loc2_].d + this[_loc2_].a - Trig.ra * this[_loc2_].d);
- _loc3_ = this[_loc2_].cy + this[_loc2_].r * Math.sin(this[_loc2_].c * this[_loc2_].d + this[_loc2_].a - Trig.ra * this[_loc2_].d);
- }
- this[_loc2_].n = this[_loc2_ + 1];
- this[_loc2_].tl = this.l;
- this.l += this[_loc2_].l;
- _loc2_ = _loc2_ + 1;
- }
- }
- function viewOffset(cts, ccd, player)
- {
- if(cts.s)
- {
- if(player.ts.s)
- {
- return 0;
- }
- var _loc11_ = Vector.lineIntersection(player.v,new Vector(player.v.x + Math.cos(player.a),player.v.y + Math.sin(player.a)),new Vector(cts.x,cts.y),new Vector(cts.x + Math.cos(cts.a),cts.y + Math.sin(cts.a)));
- var _loc8_ = cts.a - player.a;
- return Vector.vectDist(player.v,_loc11_) * Math.tan(_loc8_);
- }
- if(!player.ts.s && player.ts != cts)
- {
- var _loc13_ = new Vector(cts.cx,cts.cy);
- var _loc6_ = new Vector(cts.cx + cts.r * Math.cos(player.a),cts.cy + cts.r * Math.sin(player.a));
- var _loc5_ = new Vector(player.v.x + ccd * Math.cos(player.a),player.v.y + ccd * Math.sin(player.a));
- var _loc7_ = Vector.cpol(_loc13_,_loc6_,_loc5_);
- var _loc12_ = Vector.vectDist(_loc7_,_loc5_);
- var _loc3_ = Vector.vectDist(_loc6_,_loc7_);
- _loc3_ = _loc3_ <= cts.r ? cts.r - _loc3_ : _loc3_ % cts.r;
- var _loc10_ = Trig.xaty(cts.r,_loc3_);
- return (_loc10_ - _loc12_) * (cts.d * -1);
- }
- var _loc4_ = cts.tl - player.d;
- _loc4_ = _loc4_ > 0 ? _loc4_ : 0;
- return (cts.r - Trig.xaty(cts.r,ccd - _loc4_)) * cts.d;
- }
- function getHeightAt(ts, d)
- {
- var _loc2_ = ts.z - (!ts.n ? 0 : ts.n.z);
- return Sine.easeInOut(d - ts.tl,ts.z,- _loc2_,ts.l);
- }
- function copy()
- {
- var _loc2_ = new Track();
- for(var _loc3_ in this)
- {
- _loc2_[_loc3_] = this[_loc3_];
- }
- return _loc2_;
- }
- function toString()
- {
- var _loc3_ = "";
- var _loc2_ = 0;
- while(_loc2_ < this.length)
- {
- _loc3_ += this[_loc2_].s + ", " + this[_loc2_].l + "\n";
- _loc2_ = _loc2_ + 1;
- }
- return _loc3_;
- }
- }
-